package gridy.node;

import gridy.client.Client;
import gridy.master.Master;
import gridy.worker.Worker;

import org.apache.tuscany.sca.host.embedded.SCADomain;
import org.apache.tuscany.sca.node.SCAClient;
import org.apache.tuscany.sca.node.SCANode;
import org.apache.tuscany.sca.node.SCANodeFactory;
import org.apache.tuscany.sca.node.launcher.NodeLauncher;
import org.osoa.sca.ServiceRuntimeException;

public class LaunchClient {
    
    public static void main(String[] args) {
        
        SCANode node = null;
        try {
            
            NodeLauncher nodeLauncher = NodeLauncher.newInstance();
            node = nodeLauncher.createNodeFromURL("http://localhost:9990/node-config/NodeClient");

            node.start();
            
            // get a reference to the calculator component
            SCAClient client = (SCAClient)node;
            Client myClient = 
                client.getService(Client.class, "ClientComponent");
            
            myClient.execute();
            
            node.stop();
            
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }        
    }

}
